package com.swanclouds.redfish.managers.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.swanclouds.model.managers.Log;
import com.swanclouds.redfish.common.redfish.MemberModel;
import com.swanclouds.redfish.common.redfish.Status;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


public class LogModel implements Log {
    //日志服务信息的访问路径
    @JsonProperty("@odata.id")
    private String dataId;

    //日志服务信息的OData描述信息
    @JsonProperty("@odata.context")
    private String context;

    //日志服务信息的类型
    @JsonProperty("@odata.type")
    private String type;

    //日志服务信息的ID
    @JsonProperty("Id")
    private String id;

    //日志服务信息的名称
    @JsonProperty("Name")
    private String name;

    //允许的指定服务资源可执行操作
    @JsonProperty("Actions")
    private Map<String,Object> actions;

    //日志服务当前的时间
    @JsonProperty("DateTime")
    private String DateTime;

    //当前时间相对UTC的时间差
    @JsonProperty("DateTimeLocalOffset")
    private String DateTimeLocalOffset;

    //日志服务的描述
    @JsonProperty("Description")
    private String Description;

    //日志信息资源列表访问入口
    @JsonProperty("Entries")
    private List<MemberModel> entries;

    //日志条目类型
    @JsonProperty("LogEntryTypes")
    private String logEntryTypes;

    //日志最大的记录个数
    @JsonProperty("MaxNumberOfRecords")
    private Integer maxNumberOfRecords;

     //日志的存储策略
    @JsonProperty("OverWritePolicy")
    private String overWritePolicy;

    //日志服务使能状态
    @JsonProperty("ServiceEnabled")
    private Boolean serviceEnabled;

    /**
     * SEL日志的状态，包括：
     * Health：日志功能健康状态
     * State：日志功能使能状态
     */
    @JsonProperty("Status")
    private List<Status> status;

    @Override
    public String getDataId() {
        return this.dataId;
    }

    @Override
    public String getContext() {
        return this.context;
    }

    @Override
    public String getType() {
        return this.type;
    }

    @Override
    public String getId() {
        return this.id;
    }

    @Override
    public String getName() {
        return this.name;
    }

    public String getDateTime() {
        return DateTime;
    }

    public String getDateTimeLocalOffset() {
        return DateTimeLocalOffset;
    }

    public String getDescription() {
        return Description;
    }

    public List<MemberModel> getEntries() {
        return entries;
    }

    public String getLogEntryTypes() {
        return logEntryTypes;
    }

    @Override
    public Integer getMaxNumberOfRecords() {
        return maxNumberOfRecords;
    }

    public String getOverWritePolicy() {
        return overWritePolicy;
    }

    public Boolean getServiceEnabled() {
        return serviceEnabled;
    }

    public List<Status> getStatus() {
        return status;
    }

    public List<String> getMembers() {
        return this.entries.stream().map(MemberModel::getDataId).collect(Collectors.toList());
    }

    @Override
    public String getEntryType() {
        return null;
    }

    @Override
    public String getSeverity() {
        return null;
    }

    @Override
    public String getCreated() {
        return null;
    }

    @Override
    public String getEventTimestamp() {
        return null;
    }

    @Override
    public String getEntryCode() {
        return null;
    }

    @Override
    public String getSensorType() {
        return null;
    }

    @Override
    public String getSensorNumber() {
        return null;
    }

    @Override
    public String getMessage() {
        return null;
    }

    @Override
    public Map<String, Object> getActions() {
        return actions;
    }

    @Override
    public String toString() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
        }
        return "LogServicesModel{" +
                "dataId='" + dataId + '\'' +
                ", context='" + context + '\'' +
                ", type='" + type + '\'' +
                ", id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", actions=" + actions +
                ", DateTime='" + DateTime + '\'' +
                ", DateTimeLocalOffset='" + DateTimeLocalOffset + '\'' +
                ", Description='" + Description + '\'' +
                ", Entries=" + entries +
                ", LogEntryTypes='" + logEntryTypes + '\'' +
                ", MaxNumberOfRecords='" + maxNumberOfRecords + '\'' +
                ", OverWritePolicy='" + overWritePolicy + '\'' +
                ", ServiceEnabled='" + serviceEnabled + '\'' +
                ", status=" + status +
                '}';
    }
}
